package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.picturebrowser.view.TaskBigImgActivity;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2019/2/28
 */

public class ReplyReportListPicAdapter extends RecyclerAdapter<String, ReplyReportListPicAdapter.ReplyPicViewHolder> {

    public ReplyReportListPicAdapter(Context context, List<String> dataList) {
        super(context, dataList);
    }

    @Override
    public ReplyPicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_reply_report_list_pic, null);
        return new ReplyPicViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ReplyPicViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class ReplyPicViewHolder extends RecyclerAdapter.BaseViewHolder<String>{
        @BindView(R.id.pic_img)
        ImageView picImg;

        public ReplyPicViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(final int position) {
            String path = dataList.get(position);
            Glide.with(context)
                    .load(path)
                    .placeholder(R.drawable.default_image)
                    .error(R.drawable.default_image)
                    .into(picImg);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    TaskBigImgActivity.startActivity(context, (ArrayList<String>) dataList, position);
                }
            });
        }
    }
}
